from celery import shared_task
from django.conf import settings

from sendEmail import send_vcode
# 记录日志：
import logging

logger = logging.getLogger("django")


@shared_task(name="send_sms")
def send_sms(to_addr, smtp_server=settings.SMTP_SERVER,
             from_addr=settings.FROM_EMAIL, password=settings.EMAIL_PASSWORD,
             send_me="您好，欢迎提交你的反馈。我们会尊重每个人的意见与想法，做出实际的行动，{}"):
    """异步发送短信"""
    try:
        return send_vcode(to_addr, smtp_server, from_addr, password, send_me)
    except Exception as e:
        logger.error(f"邮箱：{smtp_server}，发送短信失败错误: {e}")


@shared_task(name="send_sms1")
def send_sms1():
    print("send_sms1执行了！！！")
